x86: protect MSI-X table and pending bit array from guest writes
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 20 Sep 2010 17:50:38 +0000 (18:50 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 20 Sep 2010 17:50:38 +0000 (18:50 +0100)
commitb5aadd4248d64249ed6d1f98659a3b35ca9e91bd
tree681b6cb265aebaf10c392334487188ea371b87cd
parent94187eb55b3334899a3b124041254e48f920ac6e
x86: protect MSI-X table and pending bit array from guest writes

These structures are used by Xen, and hence guests must not be able
to fiddle with them.

qemu-dm currently plays with the MSI-X table, requiring Dom0 to
still have write access. This is broken (explicitly allowing the guest
write access to the mask bit) and should be fixed in qemu-dm, at which
time Dom0 won't need any special casing anymore.

The changes are made under the assumption that p2m_mmio_direct will
only ever be used for order 0 pages.

An open question is whether dealing with pv guests (including the
IOMMU-less case) is necessary, as handling mappings a domain may
already have in place at the time the first interrupt gets set up
would require scanning all of the guest's L1 page table pages.
Currently a hole still remains allowing PV guests to map these ranges
before actually setting up any MSI-X vector for a device.

An alternative would be to determine and insert the address ranges
earlier into mmio_ro_ranges, but that would require a hook in the
PCI config space writes, which is particularly problematic in case
MMCONFIG accesses are being used.

A second alternative would be to require Dom0 to report all devices
(or at least all MSI-X capable ones) regardless of whether they would
be used by that domain, and do so after resources got determined/
assigned for them (i.e. a second notification later than the one
currently happening from the PCI bus scan would be needed).

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Acked-by: Jiang, Yunhong <yunhong.jiang@intel.com>
xen/arch/x86/mm.c
xen/arch/x86/mm/hap/p2m-ept.c
xen/arch/x86/mm/p2m.c
xen/arch/x86/mm/shadow/multi.c
xen/arch/x86/msi.c
xen/drivers/passthrough/io.c
xen/include/xen/iommu.h
xen/include/xen/pci.h